#ifndef CPP_RECT_H
#define CPP_RECT_H

//@brief 矩形
//@author cvte
//@description 定义矩形
class Rect {
   public:
    Rect() : mLeft(0), mTop(0), mRight(0), mBottom(0){};
    Rect(int left, int top, int right, int bottom) : mLeft(left), mTop(top), mRight(right), mBottom(bottom){};
    ~Rect(){};

    void setLeft(int left) {
        this->mLeft = left;
    }

    int getLeft() {
        return this->mLeft;
    }

    void setTop(int top) {
        this->mTop = top;
    }

    int getTop() {
        return this->mTop;
    }

    void setRight(int right) {
        this->mRight = right;
    }

    int getRight() {
        return this->mRight;
    }

    void setBottom(int bottom) {
        this->mBottom = bottom;
    }

    int getBottom() {
        return this->mBottom;
    }

    int getWidth() {
        return this->mRight - this->mLeft;
    }

    int getHeight() {
        return this->mBottom - this->mTop;
    }

    bool contains(int x, int y) {
        if (mLeft <= x && mRight > x && mTop <= y && mBottom > y) {
            return true;
        } else {
            return false;
        }
    }

   private:
    int mLeft;
    int mTop;
    int mRight;
    int mBottom;
};

#endif /* CPP_RECT_H */